#include <stdio.h>
#include <stdlib.h>
#define P(A,q) while(q>=0) fprintf(stderr,"%d", abs((A>>q--)%2));fprintf(stderr,"\n");q=31

//#define getbit(X,POS) ( (X>>(POS)) & 1 )

bool
getbit (int n, int pos)
{
	return (n >> pos) & 1;
}


void
setbit (int* n, int pos, int bit)
{
	if (bit == 1)
		*n |= 1<<pos;
	else
		*n &= ~(1<<pos);
}


int
shift (int x, int k)
{
	int ret = x;
	register short i=31;

	P(ret,i);
	k %= 32;
	if (x >= 0) {
		ret = x>>k | x << (sizeof(x) * 8 - k);
	} else {
		ret = ~x;
		ret = ret >> k | ret << (sizeof(x) * 8 - k);
		ret = ~ret;
		//x = ~x; //revert
	}
	P(ret,i);
	return ret;
}


int
main ()
{
	int x, k;
	freopen("shift.in", "r", stdin);
	freopen("shift.out", "w", stdout);
	scanf("%d%d", &x, &k);
	x = shift(x,k);
	printf("%d\n", x); //abc
	return 0;
}
